//
//  DSZGuanZhuViewController.m
//  7.13苏宁框架
//
//  Created by app05 on 15/7/19.
//  Copyright (c) 2015年 lovena. All rights reserved.
//

#import "DSZGuanZhuViewController.h"
#import "DSZStyleOneCell.h"
#import "DSZNavigationBarView.h"
#import "DSZMoreView.h"

#import "DSZMainViewController.h"
#import "HomeViewController.h"
#import "DSZShopViewController.h"

@interface DSZGuanZhuViewController ()<UITableViewDataSource,UITableViewDelegate,navigationBarDelegata,tableViewIndexPathRowDelegate>

@property(nonatomic,weak)UIView *moreView;
@property(nonatomic,assign)BOOL flag;

@end

@implementation DSZGuanZhuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIView *view=[[UIView alloc]initWithFrame:self.view.bounds];
    view.backgroundColor=[UIColor whiteColor];
    self.view=view;
    
    [self addNavBar];
    
    [self addContentView];
}

-(void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.alpha=0;
    //self.navigationController.navigationBarHidden=YES;
}
-(BOOL)prefersStatusBarHidden{
    return YES;
}
-(void)addNavBar
{
    DSZNavigationBarView *nav=[[DSZNavigationBarView alloc]initWithFrame:CGRectZero];
    nav.frame=CGRectMake(0, 20, 320, 44);
    [self.view addSubview:nav];
    nav.delegate=self;
    nav.titleLabel=@"我的关注";
}
-(void)addContentView
{
    UITableView *tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 64, 320, 170)];
    tableView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:tableView];
    tableView.delegate=self;
    tableView.dataSource=self;
    tableView.scrollEnabled=NO;
}
-(void)btnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)moreBtnClick
{
    if (!self.flag) {
        DSZMoreView *more=[DSZMoreView moreView];
        more.delegate=self;
        more.frame=CGRectMake(185, 65, 146, 186);
        self.moreView=more;
        [self.view addSubview:self.moreView];
        self.flag=YES;
    }
    else
    {
        [self.moreView removeFromSuperview];
        self.moreView=nil;
        self.flag=NO;
    }
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell=nil;
    if (indexPath.row==0) {
        DSZStyleOneCell *cellOne=[DSZStyleOneCell guanZhuCell1];
        cell=cellOne;
    }else if (indexPath.row==1) {
        DSZStyleOneCell *cellOne=[DSZStyleOneCell guanZhuCell2];
        cell=cellOne;
    }else if (indexPath.row==2) {
        DSZStyleOneCell *cellOne=[DSZStyleOneCell guanZhuCell3];
        cell=cellOne;
    }else  {
        DSZStyleOneCell *cellOne=[DSZStyleOneCell guanZhuCell4];
        cell=cellOne;
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 18;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 34;
}
-(void)dszMoreViewWithIndexRow:(NSInteger)indexPathRow
{
    if (indexPathRow==0) {
        UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        DSZMainViewController *main=[story instantiateViewControllerWithIdentifier:@"main"];
        //DSZMainViewController *main=[[DSZMainViewController alloc]init];
        [self presentViewController: main animated:NO completion:nil];
    }else if (indexPathRow==1)
    {}
    else if (indexPathRow==2)
    {
        UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        
        DSZShopViewController *shop=[story instantiateViewControllerWithIdentifier:@"shop"];
        [self.navigationController pushViewController:shop animated:NO];
        self.flag=YES;
        [self moreBtnClick];
        DSZMainViewController *main=(DSZMainViewController*)self.tabBarController;
        [main hiddenMainTabbar:YES];
    }else if (indexPathRow==3)
    {
        [self.navigationController popToRootViewControllerAnimated:YES];
        
    }
    
}

@end
